
#ifdef GL_ES						
precision lowp float;			
#endif	
							
varying vec4 v_fragmentColor;							
varying vec4 v_position;

uniform vec2 v_center;
uniform float v_radius;
uniform vec2 resolution;

float aspe = resolution.x / resolution.y;

bool isInCenter(float radius,vec2 pos,vec2 center)
{
	float dist = distance(pos, center);

	if (dist < radius)
	{
		return true;
	}

	return false;
}

float getMask(float radius,vec2 pos, vec2 center)
{
	float dist = distance(pos, center);

	if(dist < radius){
		float dd = dist/radius;

		float re = smoothstep(0.0,0.5,1.0 - pow(dd, v_fragmentColor.w));	
		return min(re,1.0);	
	}

	return 0.0;
}

vec2 transv2(vec2 point)
{
	vec2 result = point.xy / resolution.xy;
	//float aspe = resolution.x / resolution.y;
	//result = result - 0.5;
	result.x *= aspe;
	//vec2 result = (2.0*point.xy - resolution.xy)/resolution.y;
	return result;
}

float transf(float r)
{
	float re = r / resolution.y;
	re *= (0.9+0.1*cos(CC_Time[2]));
	return re;
}

void main()
{

	vec2 position = transv2(v_position.xy);
	float r = transf(v_radius);
	vec2 center = transv2(v_center);
	

	// vec2 position = v_position.xy;
	// float r = v_radius;
	// vec2 center = v_center.xy;

	if (isInCenter(r,position,center) == true)
	{
		vec4 color = v_fragmentColor;
		color.a = (1.0 - getMask(r,position,center))*v_fragmentColor.a*0.7;
		gl_FragColor = color;
	}
	else
	{
		gl_FragColor = vec4(0.0,0.0,0.0,0.0);
	}
	
}

